home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11821 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: due.unit.no!hff44-52
  2. From: davidk@james.stud.unit.no (David Kaasen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: FORTRAN and floats
  5. Date: 26 Mar 1996 17:26:02 GMT
  6. Organization: NTNU
  7. Message-ID: <4j99ba$562@due.unit.no>
  8. References: <4j6on8$fif@mozo.cc.purdue.edu>
  9. NNTP-Posting-Host: hfl216.avh.unit.no
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. Hello,
  13. I know the safest way of doing this: write the float numbers as
  14. textstrings. That is, let myFloat be a textfile and use 
  15.    fprintf(fOut,"%f",myFloat)
  16. instead. I don't know much FORTRAN, but I am sure it can read
  17. textformatted floatingpoint numbers.
  18.  
  19. David Kaasen <davidk@james.stud.unit.no>
  20.  
  21. In article <4j6on8$fif@mozo.cc.purdue.edu>, rwa@bragg.bio.purdue.edu wrote:
  22. >I write a "float" from C in Ultrix to a disk file as follows:
  23. >    fwrite(&myFloat,sizeof(float),1,fOut);
  24. >I get over to my Alpha Open VMS box and try and read it with FORTRAN and
  25. >get gibberish.  (Also can't do when writing from FORTRAN/VMS and reading in 
  26. Ultrix/C).
  27. >So FORTRAN/VMS likes a different format for floats than C/Ultrix.
  28. >This is a portability issue that I'm sure there's a "clean" way to
  29. >solve it - does anyne have any ideas for me???
  30. >Rob
  31. >rwa@babe.bio.purdue.edu
  32.